//理财直融
import api from '../../api';
import { message } from 'antd';
export default {
  namespace: 'financialProductM',
  state: {},
  effects: {
    //查询表格数据
    *getDataList({ payload, callback }, { call, put }) {
      const response = yield call(api.financialProduct.getFinancingProductList, payload);
      if (response?.code == 0) {
        callback(response.data || {});
      } else {
        callback();
        message.error(response?.msg || '查询表格失败！');
      }
    },
    //新增编辑保存操作
    *saveData({ payload, callback }, { call, put }) {
      const response = yield call(api.financialProduct.saveProduct, payload);
      if (response?.code == '0') {
        callback(true);
        message.success('操作成功！');
      } else {
        message.error(response?.msg || '保存失败！');
        return;
      }
    },
    //批量确认
    *batchConfirm({ payload, callback }, { call, put }) {
      const response = yield call(api.financialProduct.batchConfirm, payload);
      if (response?.code == '0') {
        callback(true);
      } else {
        message.error(response?.msg || '批量确认失败！');
        return;
      }
    },
  },
  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },
};
